<template>
	<view class="banquet-info">
		<view class="c-row-box">
			<view class="c-row-head"><view class="c-row-title">推广活动</view></view>
			<view class="c-row-item">
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							执行公司
						</view>
						<view class="col-text">
							<picker mode="selector" :range="companyList" range-key="title" @change="companyChange" :disabled="isPreview">
								<view>{{ selectedCompany }}</view>
							</picker>
						</view>
					</view>
				</view>
				
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							活动开始日期
						</view>
						<view class="col-text">
							<picker id="start_date" :value="activitiesParams.start_date" mode="date" :disabled="isPreview" :start="startDate" :end="endDate" @change="bindDateChange">
								<view>{{ activitiesParams.start_date ? activitiesParams.start_date : '请选择' }}</view>
							</picker>
						</view>
					</view>
				</view>
				
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							活动结束日期
						</view>
						<view class="col-text">
							<picker id="end_date" :value="activitiesParams.end_date" mode="date" :disabled="isPreview" :start="startDate" :end="endDate" @change="bindDateChange">
								<view>{{ activitiesParams.end_date ? activitiesParams.end_date : '请选择' }}</view>
							</picker>
						</view>
					</view>
				</view>
				
				<view class="c-row c-row-list">
					<view class="c-row-col c-row-col-list-item">
						<view class="col-title">
							<text style="color: red;">*</text>
							活动场地
						</view>
						<view class="col-text remark"><textarea type="text" v-model="activitiesParams.position" :disabled="isPreview" placeholder="请输入"></textarea></view>
					</view>
				</view>
			
			</view>
		</view>
	</view>
</template>

<script>
import dictionary from '@/utils/dictionary.js';
import { empty } from '../../../../utils/common';

export default {
	props: {
		isPreview: {
			type: Boolean,
			default() {
				return false;
			}
		},
		activitiesParams: {
			type: Object,
			default() {
				return {};
			}
		},
		orderParams: {
			type: Object,
			default() {
				return {};
			}
		},
		order: {
			type: Object,
			default() {
				return {};
			}
		},
		
		startDate: {
			type: String,
			default() {
				return '';
			}
		},
		endDate: {
			type: String,
			default() {
				return '';
			}
		}
	},
	data() {
		return {};
	},
	computed: {
		companyList: function() {
			let companyList = dictionary.getPicker('companyList');
			companyList = companyList.filter(ele => ele.is_valid == 1);
			
			return companyList;
		},
		selectedCompany: function() {
			return dictionary.getPickerTitle('companyList', this.activitiesParams.company_id, '请选择');
		},
	},
	beforeMount() {
		this.dictionary = dictionary;
	},
	methods: {
		// 选择公司
		companyChange(e) {
			
			let index = e.target.value;
			this.activitiesParams.company_id = this.companyList[index].id;
		},

		// 派对时间
		bindDateChange(e) {
			let id = e.target.id
			if (!id) return false;
			if (this.activitiesParams[id]!=undefined) {
				this.activitiesParams[id] = e.target.value;
			}
		}
	}
};
</script>

<style lang="less">
@import url('../../components/common.less');
@import url('../common/common.less');
</style>
